package com.swpu.cbg.cnshop.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.swpu.cbg.cnshop.R;
import com.swpu.cbg.cnshop.widget.cnToolbar;

/**
 * Created by chenboge on 16/2/22.
 */
public class PayResultActivity extends BaseActivity {


    private int status;
    @ViewInject(R.id.toolbar)
    private cnToolbar mToolbar;

    @ViewInject(R.id.id_pay_result_img)
    private ImageView mStatusImg;

    @ViewInject(R.id.id_pay_result_title)
    private TextView mStatusText;

    @ViewInject(R.id.id_pay_return)
    private Button mReturnBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_result);
        ViewUtils.inject(this);
        initToolbar();
        initStatus();
    }

    private void initStatus() {
        status = getIntent().getIntExtra("status", -1);
        ShowPayResult(status);
    }

    private void initToolbar() {

    }

    private void ShowPayResult(int status) {
        switch (status) {
            case 1:
                mStatusImg.setImageResource(R.drawable.icon_success_128);
                mStatusText.setText("支付成功");
                break;
            default:
                mStatusImg.setImageResource(R.drawable.icon_cancel_128);
                mStatusText.setText("支付失败");
                break;
        }
    }

    @OnClick(R.id.id_pay_return)
    public void Return(View view){
        Intent intent=new Intent();
        intent.setClass(this, MainActivity.class);
        startActivity(intent,false);
    }
}
